package top.zhangjianyong.tools.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import top.zhangjianyong.tools.entity.HotVideo;

import java.util.List;

public interface HotVideoMapper extends BaseMapper<HotVideo> {

    @Select("select * from (SELECT v.id,v.hot_type,v.title,v.share_url,v.author,v.item_cover,v.hot_value,v.hot_words,v.play_count,v.digg_count,v.comment_count ,IFNULL(( SELECT 1 FROM user_watched w WHERE w.user_id = #{userId} AND w.video_id = v.id LIMIT 1 ),0) as watch_flag,v.create_by,v.create_time,v.update_by,v.update_time,v.del_flag FROM hot_video v)vv ORDER BY vv.watch_flag,vv.hot_value desc LIMIT #{limit} ")
    List<HotVideo> listUserLimit(@Param("userId") Long userId, @Param("limit") int limit);
}
